home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0075_Keypress - NO Ctrl-Break.pas < prev    next >
Pascal/Delphi Source File  |  1994-02-05  |  1KB  |  41 lines

  1. {
  2.  
  3. I have a program that needed to disable Ctl-Break.  The program uses the
  4. CRT unit, and the program also used the Readkey() function and the
  5. Keypressed() function.  In order to keep Ctl-Brk from 'working' I had to
  6. replace *both* the Readkey and Keypressed functions with my own, because
  7. those functions, in the TP units, respond to Ctl-Break.  I Also had to
  8. set CheckBreak to false early in the main program routine.
  9.  
  10. The following  _Keypressed()  function uses bios interrupt 16h to test
  11. to see if a key was pressed and a keystroke is in the keyboard buffer.
  12. It is used just like the TP Keypressed function, and does not process
  13. (responed to) ctl-break. ( if _keypressed then ... ) }
  14.  
  15. function _keypressed: Boolean; Assembler;
  16.   asm
  17.      push   ds      { save TP DS reg }
  18.      push   sp      { save stack ptr }
  19.      mov    ah, 1   { int 16h fcn 1 }
  20.      int    16h     { ret zero flag clr if keypressed }
  21.      mov    al, 0   { assume false }
  22.      jz     @1      { keypressed ? }
  23.      mov    al, 1   { set true }
  24.    @1:
  25.      pop    sp
  26.      pop    ds
  27.   end;
  28. {
  29. The following _readkey function uses dos interrupt 21h function 7 to get
  30. a character from the keyboard buffer.  It does not echo the character
  31. and does not process (respond to) ctl-break.  It is used just like the
  32. TP readkey function.  ( c := _readkey; ) }
  33.  
  34. function _readkey: Char;
  35.   var regs:registers;
  36.  begin
  37.    regs.ah := 7;
  38.    msdos(regs);
  39.    _Readkey := char(regs.al);
  40.  end;
  41.